/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clusteranalyst2;

/**
 *
 * @author Administrator
 */
import Control.CCache;
import Entity.EHouse;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;

public class DataSource {   

    public HashMap getSource() {
/**
 * 注意：数据不能为空，行列都是对齐的
 */
        CCache.getCache().removeAllCluster();
        CCache cache = CCache.getCache();
        HashMap hm = new HashMap(GlobalVar.hmCapacity);
       // int count = cache.getHouseMap().size();
        /*
        HashMap houseHm=cache.getHouseMap();
        Set entry=houseHm.entrySet();
        Iterator it=entry.iterator();
        while(it.hasNext())
        {
        	Map.Entry me=(Map.Entry)it.next();
        	int keyNum=Integer.parseInt(me.getKey().toString());
            System.out.println("Key:"+keyNum);
        	
        }
        */
        
        int count=GlobalVar.hmCapacity;
        System.out.println("count:"+count);
        //int j=1;
        for (int i = 1; i <= 906; i++) {
            String HID = Integer.toString(i);   
            //System.out.println("i:"+i);
            EHouse house = (EHouse) cache.getHouseMap().get("HID" + HID);
            if (house != null) {
                int hid = house.getHID();
                System.out.println("HID:"+hid);
                String type = house.getType();
                double Darea = house.getArea();
                String arrow = house.getArrow();
                double Dfloor = house.getFloor();
                double Dprice = house.getHousePrice();
                //数值化后各因子的变量
                double Dtype;
                double Darrow;
                if (type.equals("3室2厅1卫")) {
                    Dtype = 3.0;
                } else if (type.equals("3室2厅2卫")) {
                    Dtype = 6.0;
                } else if (type.equals("4室2厅2卫")) {
                    Dtype = 9.00;
                } else if (type.equals("6室2厅5卫")) {
                    Dtype = 12.00;
                } else if (type.equals("5室3厅3卫")) {
                    Dtype = 15.00;
                } else if (type.equals("5室3厅3卫")) {
                    Dtype = 18.00;
                } else {
                    Dtype = 21.00;
                }

                if (arrow.equals("南")) {
                    Darrow = 5.00;
                } else if (arrow.equals("东南")) {
                    Darrow = 10.00;                
                }              	
                
                else {
                    Darrow = 15.00;
                }
                double[] a = new double[]{Dtype, Darea, Darrow, Dfloor, Dprice};
                hm.put(hid, a);
            } else {
                continue;
            }
        }
         GlobalVar.keyList=hm.keySet();
          //PrintMethods pm=new PrintMethods();
          //pm.printHashMap(hm);
        return hm;
       
    }
}

